package com.laikan.reader.article.adapter.holder;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.laikan.library.utils.DeviceUtil;
import com.laikan.reader.R;
import com.laikan.reader.core.LaikanApplication;
import com.laikan.reader.core.bean.BookFocusBean;

/**
 * Created by Administrator on 2016/10/21.
 */
public class TextHolder extends RecyclerView.ViewHolder{
    private BookFocusBean.BookFocusDataList bean;
    private View mRootView;
    private TextView tv_bookfocus_item_title, tv_bookfocus_author, tv_bookfocus_readtotal, tv_content, tv_focusdetail_likelook;

    public TextHolder(View view){
        super(view);
        mRootView = view;
        initView(view);
    }
    public View initView(View view) {
        tv_bookfocus_item_title = (TextView)view.findViewById(R.id.tv_bookfocus_item_title);
        tv_content = (TextView)view.findViewById(R.id.tv_content);
        tv_bookfocus_readtotal = (TextView)view.findViewById(R.id.tv_read_total);
        tv_bookfocus_author = (TextView)view.findViewById(R.id.tv_author_name);
        tv_focusdetail_likelook = (TextView)view.findViewById(R.id.tv_focusdetail_likelook);
        return view;
    }
    public void setData(BookFocusBean.BookFocusDataList bean) {
        this.bean = bean;
        refreshView(bean);
    }

    public void refreshView(BookFocusBean.BookFocusDataList bean) {
        tv_bookfocus_item_title.setText(bean.getTitle());
        tv_content.setText(bean.getIntro());
        tv_bookfocus_author.setText(bean.getAuthor());
        tv_bookfocus_readtotal.setText(DeviceUtil.getHtmlFormatedString(LaikanApplication.getInstance(), R.string.bookfocus_article_record, bean.getReadNum()));
    }
    public View getRootView() {
        return mRootView;
    }
}
